home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
framework
/
ISupEvents.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
5KB
|
163 lines
(*************************************************************************
$RCSfile: ISupEvents.mod $
Description: Extends the classes defined in Module Events to provide
the event management required by the IntuiSup library,
written as an alternative to GadTools library by Torsten
Jürgeleit.
Created by: fjc (Frank Copeland)
$Revision: 1.12 $
$Author: fjc $
$Date: 1995/06/29 18:51:33 $
Copyright © 1994-1995, Frank Copeland.
This file is part of the Oberon-A Library.
See Oberon-A.doc for conditions of use and distribution.
________________________________________________________________________
The IntuiSup library was created as an alternative to Commodore's
GadTools library. It provides almost identical facilities (plus a few
extra ones, such as a form of locale support), but unlike GadTools it
will work under Kickstart 1.3.
Like GadTools, IntuiSup requires programmers to replace calls to
Exec's GetMsg() and ReplyMsg() functions with calls to its own
functions. Unlike GadTools, IntuiSup in some cases sends the Task a
special form of IntuiMessage which must be interpreted differently to
an ordinary IntuiMessage. Special IntuiSup messages are identified by
the string "ISUP" in the Class field and the other fields of the
message have their meanings altered.
The ISupPort class is an extension of the IdcmpPort class which
overrides the methods that rely on the Exec functions and replaces
them with methods that use the IntuiSup functions. It also adds a new
method to deal with the specially formatted IntuiSup messages.
IntuiSup also provides a RequesterData structure which can be used to
create requesters that make full use of the facilities of IntuiSup
library. The ISupDialog class is an extension of the RequesterData
type that associates it with an ISupPort object. The ISupPort object
is responsible for user interaction with the requester.
*************************************************************************)
<* STANDARD- *>
<*$ NilChk- *>
(*
NIL checking is turned off and replaced with ASSERTs at the appropriate
places.
*)
MODULE ISupEvents;
IMPORT
SYS := SYSTEM, e := Exec, i := Intuition, is := IntuiSup, ev := Events,
Errors, s := Sets;
TYPE
ISupPort *= POINTER TO ISupPortRec;
ISupPortRec *= RECORD (ev.IdcmpPortRec) END;
TYPE
ISupDialog *= POINTER TO ISupDialogRec;
ISupDialogRec *= RECORD
reqData *: is.RequesterData;
iSupPort *: ISupPort;
END;
(*-----------------------------------*)
PROCEDURE (isp : ISupPort) HandleSig * () : INTEGER;
VAR result : INTEGER; msg : i.IntuiMessagePtr;
BEGIN (* HandleSig *)
result := ev.Pass; (* Default *)
ASSERT (isp.port # NIL, Errors.preCondition);
LOOP
msg := is.GetMsg (isp.port);
IF msg = NIL THEN EXIT END;
result := isp.HandleMsg (SYS.VAL (e.MessagePtr, msg));
IF result = ev.Pass THEN is.ReplyMsg (msg) END;
IF result > ev.Continue THEN EXIT END
END;
RETURN result
END HandleSig;
(*-----------------------------------*)
PROCEDURE (isp : ISupPort) HandleISup* (msg : i.IntuiMessagePtr) : INTEGER;
BEGIN (* HandleISup *)
HALT (Errors.notImplemented);
RETURN ev.StopAll
END HandleISup;
(*-----------------------------------*)
PROCEDURE (isp : ISupPort) HandleMsg* ( msg : e.MessagePtr ) : INTEGER;
VAR
intuiMessage : i.IntuiMessagePtr;
BEGIN (* HandleMsg *)
intuiMessage := SYS.VAL (i.IntuiMessagePtr, msg);
IF intuiMessage.class = SYS.VAL (SET, is.id) THEN
RETURN isp.HandleISup (intuiMessage)
ELSE
RETURN isp.HandleMsg^ (msg)
END
END HandleMsg;
(*-----------------------------------*)
PROCEDURE (isp : ISupPort) FlushPort * ();
VAR msg : i.IntuiMessagePtr;
BEGIN (* FlushPort *)
ASSERT (isp.port # NIL, Errors.preCondition);
e.Forbid ();
LOOP
msg := is.GetMsg (isp.port);
IF msg = NIL THEN EXIT END;
is.ReplyMsg (msg)
END;
e.Permit ()
END FlushPort;
(*-----------------------------------*)
PROCEDURE Activate*
( isd : ISupDialog;
window : i.WindowPtr )
: BOOLEAN;
VAR
savedIDCMP : s.SET32; rList : is.RequesterListPtr; iSupPort : ISupPort;
reqWin : i.WindowPtr;
BEGIN (* Activate *)
rList := is.DisplayRequester (window, isd.reqData, NIL);
IF rList # NIL THEN
savedIDCMP := window.idcmpFlags;
iSupPort := isd.iSupPort;
reqWin := rList.reqWindow;
iSupPort.AttachPort (reqWin.userPort);
iSupPort.SetupWindow (reqWin);
ev.SimpleLoop (iSupPort, ev.NoGC);
iSupPort.CleanupWindow (reqWin);
iSupPort.DetachPort();
is.RemoveRequester (rList);
i.OldModifyIDCMP (window, savedIDCMP);
RETURN TRUE
END;
RETURN FALSE
END Activate;
END ISupEvents.